<?php
session_start();
include_once './Data/BDDManager.inc';
include_once './classes/Partie.inc';
$bdd    = new BDDManager();
$bdd->connectBDD();
$partie = new Partie($_SESSION['idPartie'], $bdd);
$partie->update();
?>

<html>
    <head>    
        <link rel="stylesheet" type="text/css" href="./CSS/clock.css">
        <script type="text/javascript" src="./ajax/oXHR.js"></script>
        <script type="text/javascript" src="./ajax/clock.js"></script>
        <script type="text/javascript" src="./ajax/mutex.js"></script>
        <script type="text/javascript">

<?php echo('
            var idPartie=' . $_SESSION['idPartie'] . '
            var connectedPlayer="' . $_SESSION['idConnectedPlayeur'] . '"		
            // Clock 1
            var valeurH1 = ' . $partie->HRestantJ1 . ';
            var valeurM1 = ' . $partie->MRestantJ1 . ';
            var valeurS1 = ' . $partie->SRestantJ1 . ';
            // Clock 2
            var valeurH2 = ' . $partie->HRestantJ2 . ';
            var valeurM2 = ' . $partie->MRestantJ2 . ';
            var valeurS2 = ' . $partie->SRestantJ2 . ';
            var valeur_refresh = 1000;
            var valeur_refreshAll = 10000;

            // des compteurs de temps
            var decompte;
            var decompteRefresh;
            var decompteUpdateAll;	
	
            var joueurEnCours = \'' . $partie->JoueurCourant . '\';
            var enPause=' . $partie->estEnPause . ';
            var demandeNouveauJoueur ="";
	
            var toutPouvoir=false;
            window.onload = Init;
            '); ?>
        </script>
    </head>
    <body>

        <?php
        echo ('
<p>
<table>
<tr>
	<td class="margin" colspan="2">WarmaClock : L\'horloge pour jouer � Warmachine/Hordes sur Vassal(' . $_SESSION['idConnectedPlayeur'] . ') </td> 
</tr>
<tr> 
	<td>
        <CENTER class="margin">J1:
                <input class="counter" type="text" id="clock1H" value="1" MAXLENGTH="7" READONLY style="width: 25px;">
		:<input class="counter" type="text" id="clock1M" value="00" MAXLENGTH="7" READONLY style="width: 25px;">
		:<input class="counter" type="text" id="clock1S" value="00" MAXLENGTH="7" READONLY style="width: 25px;">
            
	</CENTER>
	</td> 
	<td><CENTER class="margin" >J2:<input class="counter" type="text" id="clock2H" value="1" MAXLENGTH="7" READONLY style="width: 25px;">
		       :<input class="counter" type="text" id="clock2M" value="00" MAXLENGTH="7" READONLY style="width: 25px;">
		       :<input class="counter" type="text" id="clock2S" value="00" MAXLENGTH="7" READONLY style="width: 25px;">
        </CENTER></td>
</tr>
<tr> 
	Une partie<td><CENTER><button class="margin" id="ButtonJ1" onclick="ChangeJoueurJ1J2();" onkeypress="CatchEnter()">Fin de tour</button></CENTER></td>
	<td><CENTER><button class="margin" id="ButtonJ2" onclick="ChangeJoueurJ2J1();" onkeypress="CatchEnter()">Fin de tour</button></CENTER></td>
</tr>
<tr>
	<td colspan="2"><CENTER><button class="margin" id="ButtonStart" onclick="StartOnClick();"></button></CENTER></td> 
</tr>
<tr>
	<td colspan="2"><CENTER>Joueur en cours:<div id="output">en attente...</div></CENTER></td> 
</tr>

</table>	

<div id="logVar">logVar:<br></div>
<div id="logger">log:<br></div>
</p>
');
        ?>
    </body>
</html>